<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box{
        width: 400px;
        height: 400px;
        border: 2px dashed pink;
    }
    
    </style>
</head>

<body>
    <input type="button" value="创建表格" id="btn">
    <div class="box"></div>
    <!-- <table border="1">
        <tr>
            <td></td>
            <td></td>
        </tr>

    </table> -->


    <script src="../jquery-1.12.4.js"></script>

    <script>
    var arr = [
        {name:'爱奇艺',href:'http://aiqiyi.com'},
        {name:'优酷',href:'http://youku.com'},
        {name:'土豆',href:'http://tudou.com'},
        {name:'腾讯',href:'http://qq.com'}
    ]
    var tableOjg = 
    '<table border="1">'+
        '<tr>'+
            '<td></td>'+
            '<td></td>'+
        '</tr>'+
    '</table>'
        
    $('#btn').click(function(){
        $('.box').append('<table border="1"></table>')
       
        for(var i=0;i<arr.length;i++){
            $('.box table').append('<tr></tr>')
            $('.box table tr').append('<td>'+arr[i].name+'</td>')
            $('.box table tr').append('<a href="'+arr[i].href+'">'+arr[i].name+'</a>')
        }

        
    $('.box table tr').on('click',function(){
        $(this).css('color','red')
    })

    })



    
    
    </script>
</body>

</html>